home *** CD-ROM | disk | FTP | other *** search
/ CD World Haziran 1997 / CD World Haziran 1997.iso / Programlama ve Gelistirme / DTime / _SETUP.1 / dtsetDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-04  |  2.7 KB  |  108 lines

  1. #include "stdafx.h"
  2. #include "dtset.h"
  3. #include "DtsetDlg.h"
  4. #include "dtime.h"
  5.  
  6.  
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. CDtsetDlg::CDtsetDlg(CWnd* pParent /*=NULL*/)
  14.     : CDialog(CDtsetDlg::IDD, pParent)
  15. {
  16.     //{{AFX_DATA_INIT(CDtsetDlg)
  17.     m_nGDay = 0;
  18.     m_lGYear = 0;
  19.     m_nJDay = 0;
  20.     m_lJYear = 0;
  21.     //}}AFX_DATA_INIT
  22.   m_nGMonth = 1;
  23.   m_nJMonth = 1;
  24. }
  25.  
  26.  
  27. void CDtsetDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.  
  31.     //{{AFX_DATA_MAP(CCDateDOMPage)
  32.     DDX_Control(pDX, IDC_SPINJYEAR, m_SpinJYear);
  33.     DDX_Control(pDX, IDC_SPINJDAY, m_SpinJDay);
  34.     DDX_Control(pDX, IDC_SPINGYEAR, m_SpinGYear);
  35.     DDX_Control(pDX, IDC_SPINGDAY, m_SpinGDay);
  36.     DDX_Text(pDX, IDC_JDAY, m_nJDay);
  37.     DDX_Text(pDX, IDC_JYEAR, m_lJYear);
  38.     DDX_Text(pDX, IDC_GDAY, m_nGDay);
  39.     DDX_Text(pDX, IDC_GYEAR, m_lGYear);
  40.     //}}AFX_DATA_MAP
  41.  
  42.   if (pDX->m_bSaveAndValidate)
  43.   {
  44.         DDX_CBIndex(pDX, IDC_GMONTH, (int&) m_nGMonth);
  45.         m_nGMonth++;
  46.         DDX_CBIndex(pDX, IDC_JMONTH, (int&) m_nJMonth);
  47.         m_nJMonth++;
  48.     }
  49.   else
  50.   {
  51.         int nGMonthIndex = m_nGMonth-1;
  52.         DDX_CBIndex(pDX, IDC_GMONTH, nGMonthIndex);
  53.         int nJMonthIndex = m_nJMonth-1;
  54.         DDX_CBIndex(pDX, IDC_JMONTH, nJMonthIndex);
  55.     }
  56.  
  57.     pDX->PrepareEditCtrl(IDC_JDAY);
  58.     DDV_MinMaxUInt(pDX, m_nJDay, 1, CDate::DaysInMonth(m_nJMonth, m_lJYear));
  59.     pDX->PrepareEditCtrl(IDC_GDAY);
  60.     DDV_MinMaxUInt(pDX, m_nGDay, 1, CDate::DaysInMonth(m_nGMonth, m_lGYear));
  61. }
  62.  
  63.  
  64. BEGIN_MESSAGE_MAP(CDtsetDlg, CDialog)
  65.     //{{AFX_MSG_MAP(CDtsetDlg)
  66.     //}}AFX_MSG_MAP
  67. END_MESSAGE_MAP()
  68.  
  69.  
  70. void CDtsetDlg::OnOK() 
  71. {
  72.     CDialog::OnOK();
  73.  
  74.   //Store the new settings from the registry
  75.   CDate::SetEndJulianCalendar(m_lJYear, m_nJMonth, (WORD) m_nJDay);
  76.   CDate::SetBeginGregorianCalendar(m_lGYear, m_nGMonth, (WORD) m_nGDay);
  77. }
  78.  
  79.  
  80. BOOL CDtsetDlg::OnInitDialog() 
  81. {
  82.     //Add the month strings
  83.     CComboBox* pMonthCombo1 = (CComboBox*) GetDlgItem(IDC_GMONTH);
  84.   CComboBox* pMonthCombo2 = (CComboBox*) GetDlgItem(IDC_JMONTH);
  85.     ASSERT(pMonthCombo1);
  86.   ASSERT(pMonthCombo2);
  87.     for (WORD i=1; i<13; i++)
  88.   {
  89.         pMonthCombo1->AddString(CDate::GetFullStringMonth(i));
  90.         pMonthCombo2->AddString(CDate::GetFullStringMonth(i));
  91.   }
  92.  
  93.   //retreive the default settings from the registry
  94.   CDate::GetEndJulianCalendar(m_lJYear, m_nJMonth, (WORD&) m_nJDay);
  95.   CDate::GetBeginGregorianCalendar(m_lGYear, m_nGMonth, (WORD&) m_nGDay);
  96.  
  97.   //Call up to the parent
  98.     CDialog::OnInitDialog();
  99.  
  100.   //Set the ranges for the spin controls
  101.     m_SpinJYear.SetRange(UD_MINVAL, UD_MAXVAL);
  102.     m_SpinJDay.SetRange(1, 31);
  103.     m_SpinGYear.SetRange(UD_MINVAL, UD_MAXVAL);
  104.     m_SpinGDay.SetRange(1, 31);
  105.         
  106.     return TRUE;
  107. }
  108.